# 使用官方 OpenJDK 17 镜像（slim 版本）
FROM openjdk:17-slim AS builder

WORKDIR /app
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src

# 设置 Maven 镜像源
RUN chmod +x mvnw && \
    ./mvnw clean package -DskipTests \
        -Dmaven.repo.local=/app/.m2/repository \
        -s /app/.mvn/settings.xml

# 创建运行时镜像
FROM openjdk:17-slim
WORKDIR /app
COPY --from=builder /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]